package gretha.modelsDeJTable;

import gretha.donnees.PrixDuBoisEntite;

import javax.swing.table.AbstractTableModel;

public class PrixDuBoisTableModel  extends AbstractTableModel{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7436025708601136159L;
	private PrixDuBoisEntite[] donnees;
	private String[] enTetes = {"Volume","Prix"};

	public PrixDuBoisTableModel(PrixDuBoisEntite[] data) {
		super();
		donnees = data;
	} 
	


	@Override
	public int getColumnCount() {
		return enTetes.length;
	}

	@Override
	public int getRowCount() {
		return donnees.length;
	}

	public String getColumnName(int columnIndex) {
		return enTetes[columnIndex];
	}
	
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		switch ( columnIndex ) {
		case 0 : return new Double(donnees[rowIndex].getVolume());
		case 1 : return new Double(donnees[rowIndex].getPrix());
		}
		return "";
	}
	
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return false;
	}

	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
	}
	
	public Class<? extends Object> getColumnClass(int columnIndex) {
		switch(columnIndex){
		case 0:
			return Double.class;
		case 1:
			return Double.class;
		default:
			return Object.class;
		}
	}

	public PrixDuBoisEntite[] getDonnees() {
		return donnees;
	}

	public void setDonnees(PrixDuBoisEntite[] donnees) {
		this.donnees = donnees;
	}

	public String[] getEnTetes() {
		return enTetes;
	}

	public void setEnTetes(String[] enTetes) {
		this.enTetes = enTetes;
	}
}
